const App = {
    // mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                SQLSerialNumber: 'SQL_GetTaskPlanInfoByGroup',
                PaginationNumber: 1, //页码
                RowAmount: 10,
                Condition: "",
                ExtensionCondition: '',
                Total:'',
            },
            Task_SerialNumber: "",
            tabledata: [],
            team_SerialNumber:"",
            relativePath:'',
        }
    },
    mounted() {
        
        let ls_URL = window.location.href;
        this.Task_SerialNumber = getQueryObject(ls_URL, "nodeKey");
        this.team_SerialNumber = getQueryObject(ls_URL, "team_SerialNumber");
        this.relativePath = ls_URL.substring(
            ls_URL.lastIndexOf("view"),
            ls_URL.length
        );
        this.page.ExtensionCondition = window.btoa(
            unescape(
                encodeURIComponent(
                    " where patrol_taskPlan.Row_Status='0' and  patrol_taskPlan.Task_SerialNumber='" + this.Task_SerialNumber + "'"
                )))
        console.log(" where patrol_taskPlan.Row_Status='0' and  patrol_taskPlan.Task_SerialNumber='" + this.Task_SerialNumber + "'");
        
        this.postgetList(this.page);
        // this.GetTaskPlanInfo();
    },
    methods: {
        // GetTaskPlanInfo() {
        //     $.ajax({
        //         headers: requestHeaders(),
        //         url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
        //         type: "post",
        //         data: {
        //             SQLSerialNumber: "SQL_GetTaskPlanInfoByGroup",
        //             Condition: "",
        //             ExtensionCondition: window.btoa(
        //                 unescape(
        //                     encodeURIComponent(
        //                         " where patrol_taskPlan.Row_Status='0' and  patrol_taskPlan.Task_SerialNumber='" + this.Task_SerialNumber + "'"
        //                     ))),
        //         },
        //         success: (TaskPlanInfo) => {

        //             this.tabledata = TaskPlanInfo;

        //         },
        //         complete: (XMLHttpRequest) => {
        //             requestPretreatment(XMLHttpRequest);
        //         },
        //         dataType: "json",
        //     })
        // },
        goBack() {
            // window.history.back();
            window.location.href = "./index.html";
        },
        handleMember(row) {
            let _taskPlan_SerialNumber = row.taskPlan_SerialNumber;
            let _team_SerialNumber = row.team_SerialNumber
            window.location.href = "./memberAdd.html?action=Modify&team_SerialNumber=" + _team_SerialNumber + "&nodeKey=" + _taskPlan_SerialNumber + "&Task_SerialNumber=" + this.Task_SerialNumber;
        },

        PlanAdd() {

            

            window.location.href = "./PlanAdd.html?action=Add&team_SerialNumber=" + this.team_SerialNumber + "&Task_SerialNumber=" + this.Task_SerialNumber;
        },
        handleSizeChange(newSize) {
            this.page.PaginationNumber = 1;
            this.page.RowAmount = newSize;
            this.postgetList(this.page);
        },
        handleCurrentChange(newPage) {
            this.page.PaginationNumber = newPage;
            this.postgetList(this.page);
        },
        //获取表格的数据
        postgetList(data) {
            const that = this;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
                method: "post",
                data,
                success: (res) => {
                    that.Total = res.TotalRows;//总数量
                    that.loading = false;
                    that.tabledata = res.Rows;
                    submitSave({
                        Add: {
                            base_operation_log: [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main: JSON.stringify(deepClone({
                                    Data: res.Rows,
                                    Param: data
                                })),
                                Operation_Interface: "generalPaginationQueryBySQLSerialNumber",
                                Operation_IP: getIpAddress()
                            }]
                        }
                    })

                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
            });

        },
        handleDelete(data) {
            this.$confirm('该操作将删除此条数据,是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                let { TableName, primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
                    method: "post",
                    data: {
                        Data: TableName,
                        Condition: primary_key + "='" + data[primary_key] + "'"
                    },
                    success: (res) => {
                        if (res.length == 1) {
                            res[0].Row_Status = '1';
                            let lJSONObject_DataSet = new Object();
                            let lJSONObject_Table = new Object();
                            lJSONObject_Table[TableName] = res;
                            lJSONObject_DataSet['Modify'] = lJSONObject_Table;
                            let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
                            lJSONObject_DataSet['Add'] = new Object();
                            lJSONObject_DataSet['Add']['base_operation_log'] = [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main,
                                Operation_Interface: "generalSaveByRequestBody",
                                Operation_IP: getIpAddress()
                            }]
                            submitSave(lJSONObject_DataSet, (res) => {
                                if (res.Status == 'success') {
                                    this.postgetList(this.page);
                                } else {
                                    this.$message({
                                        type: 'error',
                                        message: '删除失败'
                                    });
                                }
                            })
                            
                        } else {
                            this.$message({
                                type: 'error',
                                message: '删除失败'
                            });
                        }

                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest)
                    },
                });
            }).catch(() => { });
        }
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
